home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / tclMotif-1.4 / programs / bug1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-29  |  1.0 KB  |  50 lines

  1.  
  2. /*
  3.  * Elmt first put into list gets killed when 2nd elmt is added.
  4.  * This shows both visually and in XmStringCompare
  5.  */
  6.  
  7. #include <Xm/List.h>
  8.  
  9. int
  10. main(argc, argv)
  11.     int argc;
  12.     char **argv;
  13. {
  14.     Widget list;
  15.     XtAppContext app;
  16.     Widget toplevel;
  17.     XmString str1, str2;
  18.     Arg args[10];
  19.     int n = 0;
  20.     XmString *items;
  21.  
  22.     toplevel = XtAppInitialize(&app, "XmSend", NULL, 0, &argc, argv,
  23.                 NULL, NULL, 0);
  24.  
  25.  
  26.     XtSetArg(args[n], XmNvisibleItemCount, 3); n++;
  27.     list = XmCreateList(toplevel, "top_list", args, n);
  28.     XtManageChild(list);
  29.  
  30.     str1 = XmStringCreateLocalized("fred");
  31.     str2 = XmStringCreateLocalized("bill");
  32.  
  33.     XmListAddItem(list, str1, 1);
  34.     XmListAddItem(list, str2, 1);
  35.  
  36.     XtVaGetValues(list, XmNitems, &items, NULL);
  37.     if (XmStringCompare(str2, items[0]))
  38.     printf("1st item same\n");
  39.     else
  40.     printf("1st item differs\n");
  41.     if (XmStringCompare(str1, items[1]))
  42.     printf("2nd item same\n");
  43.     else
  44.     printf("2nd item differs\n");
  45.  
  46.     XtRealizeWidget(toplevel);
  47.  
  48.     XtAppMainLoop(app);
  49. }
  50.